TK!2
=v
#1
:n
number
:v
40330512650745200
:s
i
:c
a number to be factorized
=u
=l
#1
:n
P
:v
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
101
103
107
109
113
127
131
137
139
149
151
157
163
167
173
179
181
191
193
197
199
211
223
227
229
233
239
241
251
257
263
269
271
277
281
283
293
307
311
313
317
331
337
347
349
353
359
367
373
379
383
389
397
401
409
419
421
431
433
439
443
449
457
461
463
467
479
487
491
499
503
509
521
523
541
547
557
563
569
571
577
587
593
599
601
607
613
617
619
631
641
643
647
653
659
661
673
677
683
691
701
709
719
727
733
739
743
751
757
761
769
773
787
797
809
811
821
823
827
829
839
853
857
859
863
877
881
883
887
907
911
919
929
937
941
947
953
967
971
977
983
991
997
E
#2
:n
Value
:v
2
5
13
23
953
E
#3
:n
Count
:v
4
2
6
1
2
E
=f
#1
:n
factors
:c
Factorization of a positive integer into primes
:t
Procedure
:i
N
#1
:n
factors
:z
" Description:
" The input variable is decomposed into prime factors through a sequence
" of divisions by primes in ascending order. The procedure must be supported
" by a list of primes  P .
" The results are stored in the lists  Value  and  Count .

" Note: If the available list of prime numbers  P  is not long enough to
" handle given  N , additional prime numbers may be obtained from files
"     PRM10000.ASC  . . .  primes from      2 < x < 10000  interval
"     PRM20000.ASC  . . .  primes from  10000 < x < 20000  interval
"     PRM30000.ASC  . . .  primes from  20000 < x < 30000  interval
" and copied into the list  P .

call blank('Value)
call blank('Count)
j:= 0
k:= 0
for i=1 to length('P)
   if j>0 then 'Count[k]:= j
   if N=1 return
   j:= 0
more: M:= N/'P[i]
   if M<>int(M) goto nextP
   N:= M
   j:= j + 1
   if j>1 goto more
   k:= k + 1
   'Value[k]:= 'P[i]
   goto more
nextP: next i
error:= number_too_large_for_available_list_of_primes   " see note above
/E
E
=r
#1
:r
"  ***  Factorization of whole numbers into primes  ***
:s
C
#3
:r
call factors(number)
#5
:r
" Note: Press F8 to see the results for number = 4033051265074520000 .
:s
C
#7
:r
"       See the Function Subsheet 'factors' for additional notes.
:s
C
=p
=t
#1
:n
results
:s
Screen
:v
Vertical
:f
1
:r
"Í"
:c
"³"
:t
"Factors of 40330512650745200"
:u
#1
:l
Value
:n
right2
:w
8
:h
""
#2
:l
Count
:n
right2
:w
6
:h
""
E
=n
#1
:n
right2
:d
15
:f

:^
Either Scientific or Decimal
:e
"."
:m
""
:p
None
:j
Right
:s
- Only
:q
0
:x
2
:l
""
:t
""
:v
"0  "
=g
#1
:c
.000001
:i
10
:v
Yes
:l
60
:f
66
:m
0
:w
80
:b
Yes
:a
Yes
:r
Yes
:h
No
:t
1
:n
Yes
:d
LPT1
%Br,f,0,1,0,1,0
%Ov,f,0,1,0,1,0
